package com.binfast.codegen.gen;

import com.binfast.codegen.gen.genTarget.Target;
import com.binfast.codegen.gen.model.Entity;
import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;

public class HtmlGen  implements AutoGen {

	@Override
	public void make(Target target, Entity entity) {
		
		HtmlIndexGen indexGen = new HtmlIndexGen();
		indexGen.make(target, entity);
		
		HtmlEditGen editGen = new HtmlEditGen();
		editGen.make(target, entity);
		
//		HtmlAddGen addGen = new HtmlAddGen();
//		addGen.make(target, entity);
	}
	
	@Override
	public String getName() {
		return "";
	}
	
}


class HtmlIndexGen  implements AutoGen {
	
	@Override
	public void make(Target target, Entity entity) {
		GroupTemplate gt = target.getGroupTemplate();
		Template template = gt.getTemplate("/vue/list.vue");
		template.binding("entity", entity);
		template.binding("target", target);
		String content = template.render();
		target.flush(this, content);
	}

	@Override
	public String getName() {
		return "list.vue";
	}
	
}

class HtmlEditGen  implements AutoGen {
	
	@Override
	public void make(Target target, Entity entity) {
		GroupTemplate gt = target.getGroupTemplate();
		Template template = gt.getTemplate("/vue/detail.vue");
		template.binding("entity", entity);
		template.binding("target", target);
		String content = template.render();
		target.flush(this, content);
	}
	@Override
	public String getName() {
		return "detail.vue";
	}
	
}

//class HtmlAddGen  implements AutoGen{
//
//	@Override
//	public void make(Target target, Entity entity) {
//		GroupTemplate gt = target.getGroupTemplate();
//		Template template = gt.getTemplate("/html/add.html");
//		template.binding("entity", entity);
//		template.binding("target", target);
//		String content = template.render();
//		target.flush(this, content);
//	}
//	@Override
//	public String getName() {
//		return "add.html";
//	}
//
//}




